home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1196 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: lemond.sps.mot.com!sem
  2. From: sem@lemond.sps.mot.com (Steve Montgomery)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help with CEdit.GetLine
  5. Date: 9 Jan 96 18:17:30 GMT
  6. Organization: Motorola (Austin,TX)
  7. Message-ID: <sem.821211450@lemond.sps.mot.com>
  8. References: <DKw0o2.4xJ@freenet.carleton.ca>
  9. NNTP-Posting-Host: lemond.sps.mot.com
  10. X-Newsreader: NN version 6.5.0 #2 (NOV)
  11.  
  12. In <DKw0o2.4xJ@freenet.carleton.ca> cf949@FreeNet.Carleton.CA (Frantisek Fisl) writes:
  13.  
  14.  
  15. >Hi experts! Could anyone post some code showing how to use the
  16. >CEdit.GetLine function to retrieve a line of text from an edit control in
  17. >a dialog box and convert it to a number?
  18.  
  19. >Thanks for any help!
  20.  
  21. >Frank
  22.  
  23. Sounds like your using the MFC. See the online help for DoDataExchange
  24.  
  25. Code in the DoDataExchange function would look like:
  26.  
  27.     DDX_Text(pDX, IDC_CONTROL_ID, m_IntVariable);
  28.     DDV_MinMaxInt(pDX, m_IntVariable, 50, 5000);
  29.  
  30. You need to do an UpdateData(TRUE) to exchange the data from the control
  31. to the variable and UpdateData(FALSE) to go the other way.
  32.  
  33. The DDX function does the exchange, the DDV function validates it in a
  34. range from 50 to 5000 (use your own numbers). There are a whole series of
  35. exchange and validation functions available, and you can role your own as well.
  36.  
  37. A more brute force approach would be to get the text directly from
  38. the control using:
  39.     CWnd* pWnd = GetDlgItem(IDC_CONTROL_ID);
  40.     CString sWindowText;
  41.     pWnd->GetWindowText(sWindowText);
  42.     m_IntVariable = atoi(sWindowText.GetBuffer(0));
  43.  
  44. Hope this helps!
  45.  
  46. Steve M.
  47.  
  48.  
  49. -- 
  50. Steven E. Montgomery
  51. Motorola, Microcontroller Software Applications
  52. email:    sem@lemond.sps.mot.com
  53. voice:    512-891-7321
  54.